package com.csii.core.util;

import lombok.extern.slf4j.Slf4j;

/**
 * 多租户 tenant_id存储器
 */
@Slf4j
public class TenantContext {

	private static ThreadLocal<String> currentTenant = new ThreadLocal<>();

	public static void setTenant(String tenant) {
		currentTenant.set(tenant);
	}

	public static String getTenant() {
		return currentTenant.get();
	}

	public static String getTenantDefaultString() {
		String tenantId = currentTenant.get();
		return tenantId == null ? "" : tenantId;
	}

	public static void clear() {
		currentTenant.remove();
	}
}
